<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

    <div id="wrap">wrap</div>
    <div id="goudan">goudan</div>


    <script>
        let oWrap = document.getElementById("wrap"),
            oGoudan = document.getElementById("goudan");

        /*function a() {

        }

        if(document.addEventListener){
            oWrap.addEventListener("click",a)
        }else {
            oWrap.attachEvent("onclick",function () {
                a.call(oWrap,window.event)
            })
        }

        function b() {

        }

        if(document.addEventListener){
            oGoudan.addEventListener("click",b)
        }else {
            oGoudan.attachEvent("onclick",function () {
                b.call(oGoudan,window.event)
            })
        }*/

        function addEvent(ele,eName,eFn) {
            if (document.addEventListener){
                ele.addEventListener(eName,eFn)
            }else{
                ele.attachEvent("on"+eName,function () {
                    eFn.call(ele,window.event)
                })
            }
        }

        addEvent(oWrap,"click",function (e) {
            alert(e.clientX)
        })

        addEvent(oGoudan,"click",function (e) {
            alert(e)
        })
    </script>

</body>
</html>